package bus;

import java.util.Iterator;
import java.util.List;

import org.mattpayne.jrac.people.dao.PeopleDao;
import org.mattpayne.jrac.people.dao.PeopleDaoExeception;

public class PersonManager {

	private PeopleDao dao;

	public void setDao(PeopleDao dao) {
		this.dao = dao;
		p("!!!!!!\n!!!!!!!\n!!!!!!!!!\nJust set dao=" + dao);
	}

	public List getPeople() {
		return dao.getPeople();
	}

	public void setPeople(List people) {
		for (Iterator it = people.iterator(); it.hasNext();) {
			Person p = (Person) it.next();
			try {
				dao.savePerson(p);
			} catch (PeopleDaoExeception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void addPerson(Person person) throws PeopleDaoExeception {
		dao.addPerson(person);
}
	
	public void savePerson(Person person) throws PeopleDaoExeception {
			dao.savePerson(person);
	}

	public void deletePerson(Person person) throws PeopleDaoExeception {
		dao.deletePerson(person);
	}
	
	private void p(String msg) {
		System.out.println("PM "+msg);
	}
}
